package com.burns.leetcode.d1t;

public class Main {
    public static void main(String[] args) {
        int[] nums= {2,7,11,15};
        int target=9;
        int[] ints = twoSum(nums, target);
        System.out.println("数组下标："+ints[0]+","+ints[1]);
    }

    public static int[] twoSum(int[] nums, int target) {
        int[] result=null;
        for(int i=0;i<nums.length;i++){
            for(int j=i+1;j<nums.length;j++){
                if(nums[i]+nums[j]==target){
                    result=new int[2];
                    result[0]=i;
                    result[1]=j;
                    break;
                }
            }
            if(result!=null){
                break;
            }
        }
        return result;
    }
}
